package com.ruoyi.neusoft.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.neusoft.domain.AiIdentifyModelClassifyT;
import com.ruoyi.neusoft.service.IAiIdentifyModelClassifyTService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AI模型训练分类Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@Controller
@RequestMapping("/AI/ClassifyService")
public class AiIdentifyModelClassifyTController extends BaseController
{
    private String prefix = "AI/ClassifyService";

    @Autowired
    private IAiIdentifyModelClassifyTService aiIdentifyModelClassifyTService;

    @RequiresPermissions("AI:ClassifyService:view")
    @GetMapping()
    public String ClassifyService()
    {
        return prefix + "/ClassifyService";
    }

    /**
     * 查询AI模型训练分类列表
     */
    @RequiresPermissions("AI:ClassifyService:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AiIdentifyModelClassifyT aiIdentifyModelClassifyT)
    {
        startPage();
        List<AiIdentifyModelClassifyT> list = aiIdentifyModelClassifyTService.selectAiIdentifyModelClassifyTList(aiIdentifyModelClassifyT);
        return getDataTable(list);
    }

    /**
     * 导出AI模型训练分类列表
     */
    @RequiresPermissions("AI:ClassifyService:export")
    @Log(title = "AI模型训练分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AiIdentifyModelClassifyT aiIdentifyModelClassifyT)
    {
        List<AiIdentifyModelClassifyT> list = aiIdentifyModelClassifyTService.selectAiIdentifyModelClassifyTList(aiIdentifyModelClassifyT);
        ExcelUtil<AiIdentifyModelClassifyT> util = new ExcelUtil<AiIdentifyModelClassifyT>(AiIdentifyModelClassifyT.class);
        return util.exportExcel(list, "AI模型训练分类数据");
    }

    /**
     * 新增AI模型训练分类
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AI模型训练分类
     */
    @RequiresPermissions("AI:ClassifyService:add")
    @Log(title = "AI模型训练分类", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AiIdentifyModelClassifyT aiIdentifyModelClassifyT)
    {
        return toAjax(aiIdentifyModelClassifyTService.insertAiIdentifyModelClassifyT(aiIdentifyModelClassifyT));
    }

    /**
     * 修改AI模型训练分类
     */
    @RequiresPermissions("AI:ClassifyService:edit")
    @GetMapping("/edit/{classifyUuid}")
    public String edit(@PathVariable("classifyUuid") Long classifyUuid, ModelMap mmap)
    {
        AiIdentifyModelClassifyT aiIdentifyModelClassifyT = aiIdentifyModelClassifyTService.selectAiIdentifyModelClassifyTByClassifyUuid(classifyUuid);
        mmap.put("aiIdentifyModelClassifyT", aiIdentifyModelClassifyT);
        return prefix + "/edit";
    }

    /**
     * 修改保存AI模型训练分类
     */
    @RequiresPermissions("AI:ClassifyService:edit")
    @Log(title = "AI模型训练分类", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AiIdentifyModelClassifyT aiIdentifyModelClassifyT)
    {
        return toAjax(aiIdentifyModelClassifyTService.updateAiIdentifyModelClassifyT(aiIdentifyModelClassifyT));
    }

    /**
     * 删除AI模型训练分类
     */
    @RequiresPermissions("AI:ClassifyService:remove")
    @Log(title = "AI模型训练分类", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aiIdentifyModelClassifyTService.deleteAiIdentifyModelClassifyTByClassifyUuids(ids));
    }
}
